import { defineStore } from 'pinia';
import service from '/@/utils/request';

export const useDivision = defineStore('division', {
	state: () => ({
		divisions: [],
	}),
	actions: {
		async getDivisions() {
			if (this.divisions.length > 0) {
				return Promise.resolve(this.divisions);
			} else {
				return service.get('/api/division').then((res) => {
					this.divisions = res.data;
					return res.data;
				});
			}
		},
	},
});
